package com.lsy.weizhi2.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lsy.weizhi2.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;


/**
 * Created by 嗨哟 on 2017/4/6.
 */
public class WeiYouImageAdapter extends BaseAdapter {
    private Context context;
    private List<?> list;
    private LayoutInflater layoutInflater;

    public WeiYouImageAdapter(Context context, List<?> list) {
        this.context = context;
        this.list = list;
        layoutInflater=LayoutInflater.from(context);
    }

    public void Updata(List<?> list){
        this.list=list;
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list==null?8:list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        GridHolder holder;
        if(view==null){
            view=layoutInflater.inflate(R.layout.imageitem3,viewGroup,false);
            holder=new GridHolder();
            holder.imageView= (ImageView) view.findViewById(R.id.imageView);
            holder.name= (TextView) view.findViewById(R.id.name);
            AutoUtils.autoSize(view);
            view.setTag(holder);
        }else{
            holder= (GridHolder) view.getTag();
        }
        holder.imageView.setImageResource(R.mipmap.weiyou_image);
        holder.name.setText("萱萱");
        return view;
    }

    class GridHolder{
        ImageView imageView;
        TextView name;
    }
}
